package hudson.plugins.aspen;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Result;

public class AspenProjectAction implements Action {

	public final AbstractProject<?, ?> project;
	
	public AspenProjectAction(AbstractProject<?, ?> project) {
		this.project = project;
	}

	public String getDisplayName() {
		return "Aspen Report";
	}

	public String getIconFileName() {
		return "graph.gif";
	}

	public String getUrlName() {
		return "aspen";
	}
	
	public AspenBuildAction getLastBuild(){
		for( AbstractBuild<?,?> b = project.getLastBuild(); b!=null; b=b.getPreviousBuild()) {
            AspenBuildAction r = b.getAction(AspenBuildAction.class);
            if(r!=null)
                return r;
        }
        return null;
	}

}
